WIFI_SSV6158_SITE_METHOD = git
WIFI_SSV6158_SITE = https://github.com/wltechblog/wifi-ssv6158
WIFI_SSV6158_SITE_BRANCH = main
WIFI_SSV6158_VERSION = a2afa9d80568895edd8875841137103801b51859
# $(shell git ls-remote $(WIFI_SSV6158_SITE) $(WIFI_SSV6158_SITE_BRANCH) | head -1 | cut -f1)

WIFI_SSV6158_LICENSE = GPL-2.0
WIFI_SSV6158_LICENSE_FILES = COPYING

WIFI_SSV6158_MODULE_MAKE_OPTS = \
	KSRC=$(LINUX_DIR)

ifeq ($(BR2_PACKAGE_THINGINO_BLUETOOTH),y)
define WIFI_SSV6158_LINUX_CONFIG_FIXUPS
	$(call KCONFIG_ENABLE_OPT,CONFIG_WLAN)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS_EXT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_CORE)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PROC)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PRIV)
	$(call KCONFIG_SET_OPT,CONFIG_CFG80211,y)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211,y)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL_HT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_DEFAULT_MINSTREL)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211_RC_DEFAULT,"minstrel_ht")
	$(call KCONFIG_SET_OPT,CONFIG_BT,y)
	$(call KCONFIG_ENABLE_OPT,CONFIG_BT_HCIBTSDIO)
endef
else
define WIFI_SSV6158_LINUX_CONFIG_FIXUPS
	$(call KCONFIG_ENABLE_OPT,CONFIG_WLAN)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WIRELESS_EXT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_CORE)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PROC)
	$(call KCONFIG_ENABLE_OPT,CONFIG_WEXT_PRIV)
	$(call KCONFIG_SET_OPT,CONFIG_CFG80211,y)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211,y)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_MINSTREL_HT)
	$(call KCONFIG_ENABLE_OPT,CONFIG_MAC80211_RC_DEFAULT_MINSTREL)
	$(call KCONFIG_SET_OPT,CONFIG_MAC80211_RC_DEFAULT,"minstrel_ht")
endef
endif

define WIFI_SSV6158_COPY_CONFIG
	$(INSTALL) -D -m 0644 $(WIFI_SSV6158_PKGDIR)/files/ssv6x5x-wifi.cfg \
		$(TARGET_DIR)/usr/share/wifi/ssv6x5x-wifi.cfg
endef

WIFI_SSV6158_PRE_CONFIGURE_HOOKS += WIFI_SSV6158_COPY_CONFIG

ifeq ($(BR2_PACKAGE_THINGINO_BLUETOOTH),y)
define WIFI_SSV6158_ENABLE_BLE_CONFIG
	echo 'ccflags-y += -DCONFIG_BLE' >> $(@D)/config_common.mak
endef

WIFI_SSV6158_PRE_CONFIGURE_HOOKS += WIFI_SSV6158_ENABLE_BLE_CONFIG
endif

$(eval $(kernel-module))
$(eval $(generic-package))
